using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;
using XBLib.Dal.AdoDal;
using DataInfo;
using KenLib.Common;
namespace KenLib.Dal
{
    public class 出入国歴情報Dao : BaseAdoDao
      {
          private string m_requestTime;
          private string m_displayTime;
          public int Insert(出入国歴情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param1 = _daoHelper.CreateParameter("@入国予定年月日", obj.入国予定年月日, DbType.DateTime);
                  DbParameter param2 = _daoHelper.CreateParameter("@入国年月日", obj.入国年月日, DbType.DateTime);
                  DbParameter param3 = _daoHelper.CreateParameter("@再入国年月日", obj.再入国年月日, DbType.DateTime);
                  DbParameter param4 = _daoHelper.CreateParameter("@入国特記事項", obj.入国特記事項, DbType.String);
                  DbParameter param5 = _daoHelper.CreateParameter("@上陸港", obj.上陸港, DbType.String);
                  DbParameter param6 = _daoHelper.CreateParameter("@出国予定年月日", obj.出国予定年月日, DbType.DateTime);
                  DbParameter param7 = _daoHelper.CreateParameter("@出国年月日", obj.出国年月日, DbType.DateTime);
                  DbParameter param8 = _daoHelper.CreateParameter("@出国特記事項", obj.出国特記事項, DbType.String);
                  DbParameter param9 = _daoHelper.CreateParameter("@帰国ステータス", obj.帰国ステータス, DbType.Int32);
                  DbParameter param10 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Insert_HumanImmiHistoryInfo, CommandType.StoredProcedure, param20, param1, param2, param3, param4, param5, param6, param7, param8,param9,param10);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "INSERT", "Insert_HumanImmiHistoryInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Update(出入国歴情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
                  DbParameter param1 = _daoHelper.CreateParameter("@入国予定年月日", obj.入国予定年月日, DbType.DateTime);
                  DbParameter param2 = _daoHelper.CreateParameter("@入国年月日", obj.入国年月日, DbType.DateTime);
                  DbParameter param3 = _daoHelper.CreateParameter("@再入国年月日", obj.再入国年月日, DbType.DateTime);
                  DbParameter param4 = _daoHelper.CreateParameter("@入国特記事項", obj.入国特記事項, DbType.String);
                  DbParameter param5 = _daoHelper.CreateParameter("@上陸港", obj.上陸港, DbType.String);
                  DbParameter param6 = _daoHelper.CreateParameter("@出国予定年月日", obj.出国予定年月日, DbType.DateTime);
                  DbParameter param7 = _daoHelper.CreateParameter("@出国年月日", obj.出国年月日, DbType.DateTime);
                  DbParameter param8 = _daoHelper.CreateParameter("@出国特記事項", obj.出国特記事項, DbType.String);
                  DbParameter param9 = _daoHelper.CreateParameter("@帰国ステータス", obj.帰国ステータス, DbType.Int32);
                  DbParameter param10 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Update_HumanImmiHistoryInfo, CommandType.StoredProcedure,param20, param0, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "UPDATE", "Update_HumanImmiHistoryInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Delete(int id)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", id, DbType.Int32);

                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Delete_HumanImmiHistoryInfo, CommandType.StoredProcedure, param0);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "DELETE", "Delete_HumanImmiHistoryInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }
          public DataTable Select上陸港() 
          {
              DbCommand dbcommand = _daoHelper.CreateCommand("sp_select_上陸港_Hunglt", CommandType.StoredProcedure);
              return _daoHelper.Query(dbcommand);
          }

          #region TUNG
          public DataTable getGrv_出入国歴(int 社員ID)
          {
              DbParameter dbParam1 = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
              DbCommand dbcommand = _daoHelper.CreateCommand("sp_getGrv_出入国歴_TUNG", CommandType.StoredProcedure, dbParam1);
              return _daoHelper.Query(dbcommand);
          }
          #endregion

          #region Hunglt
          public void InsertInfo出入国歴情報(出入国歴情報 obj, int 社員ID)
          {
              DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
              DbParameter param入国予定年月日 = _daoHelper.CreateParameter("@入国予定年月日", obj.入国予定年月日, DbType.DateTime);
              DbParameter param入国年月日 = _daoHelper.CreateParameter("@入国年月日", obj.入国年月日, DbType.DateTime);
              DbParameter param入国特記事項 = _daoHelper.CreateParameter("@入国特記事項", obj.入国特記事項, DbType.String);
              DbParameter param上陸港 = _daoHelper.CreateParameter("@上陸港", obj.上陸港, DbType.Int32);
              DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);

              DbCommand command = _daoHelper.CreateCommand("sp_Insert_出入国歴情報_Hunglt", CommandType.StoredProcedure,
                 param廃止区分, param入国予定年月日, param入国年月日, param入国特記事項, param上陸港, param社員ID);
              _daoHelper.Query(command);
          }
          public void UpdateInfo出入国歴情報(出入国歴情報 obj, int 社員ID)
          {
              DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
              DbParameter param入国予定年月日 = _daoHelper.CreateParameter("@入国予定年月日", obj.入国予定年月日, DbType.DateTime);
              DbParameter param入国年月日 = _daoHelper.CreateParameter("@入国年月日", obj.入国年月日, DbType.DateTime);
              DbParameter param入国特記事項 = _daoHelper.CreateParameter("@入国特記事項", obj.入国特記事項, DbType.String);
              DbParameter param上陸港 = _daoHelper.CreateParameter("@上陸港", obj.上陸港, DbType.Int32);
              DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);

              DbCommand command = _daoHelper.CreateCommand("sp_Update_出入国歴情報_Hunglt", CommandType.StoredProcedure,
                 param廃止区分, param入国予定年月日, param入国年月日, param入国特記事項, param上陸港, param社員ID);
              _daoHelper.Query(command);
          }
          #endregion
      }
}
